import React from 'react'
import style from './Index.module.less'
import { strToNum } from '@src/assets/js/tool'

function formatValue (data) {
  data.value = strToNum(data.value)
  if (data.value && data.typeconfig && data.typeconfig.isMoney) {
    return `$ ${data.value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',') + '元'
  }
  return data.value || '无'
}

function Main ({ data }) {
  return (
    <div className={style.container}>
      <div className={style.label}>{data.title}</div>
      <div className={style.value}>{formatValue(data)}</div>
    </div>
  )
}

export default Main
